package top.kent90.common.controller;


import top.kent90.common.object.LoginObject;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;


public class BaseController {

	/**
	 * 用户信息
	 */
	public static final String SESSION_USER_KEY = "UserInfo";

	/**
	 * 用户权限
	 */
//	public static final String USER_POPEDOM_KEY = "UserPopedom";

    /**
	 * Session
	 * @param request
	 * @return
	 */
	public HttpSession getSession(HttpServletRequest request){
		return request.getSession();
	}
	
	
	public Map<String,Object> param(){
		Map<String,Object> map = new HashMap<>();
		return map;
		
	}
	
	public Object getUserId(HttpServletRequest request){
		return getLoginObject(request).getUserId();
	}
	
	public Object getUserName(HttpServletRequest request){
		return getLoginObject(request).getUserName();
	}
	
	public LoginObject getLoginObject(HttpServletRequest request){
		return (LoginObject)request.getSession().getAttribute(SESSION_USER_KEY);
	}
	
}
